package edu.luc.etl.jbunit.tl;

/**
 * The formula <code>always p</code> specifies that <code>p</code>
 * must have been true for the entire past history of this system run.
 */

public class AllPast<T> extends Expr<T> { // has-always-been

  private Expr<T> p;

  public AllPast(Expr<T> p) {
    this.p = p;
    val = true;
  }

  public AllPast(T arg) {
    this(new Leaf<T>(arg));
  }

  public AllPast<T> clone() {
    AllPast<T> result = (AllPast<T>) super.clone();
    result.p = p.clone();
    return result;
  }

  public void reset () { p.reset(); }

  public void tick () { evaluated = false; p.tick(); }

  boolean ev () {
    boolean cp = p.valuate();

    val = val ? cp : false;
    return val;
  }

  void accept(Visitor<T> v) {
    v.visitAllPast(this);
    p.accept(v);
  }
}
